package com.example.myapplication;

import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        if (AppConstants.ENABLE_NEWS_FEATURE) {
            setContentView(R.layout.activity_news_list);
            // 初始化新闻列表 Fragment
            if (savedInstanceState == null) {
                getSupportFragmentManager().beginTransaction()
                    .add(R.id.list_container, new NewsListFragment())
                    .commit();
            }
        } else {
            setContentView(R.layout.activity_main);
            Button btn = findViewById(R.id.btn);
            btn.setOnClickListener(v -> {
                // 跳转到 SecondActivity 并显示 Toast
                startActivity(new Intent(MainActivity.this, SecondActivity.class));
            });
        }
    }
}